package com.sailfish.springbootdemo.controller.db1;

import com.sailfish.springbootdemo.pojo.Result;
import com.sailfish.springbootdemo.pojo.db1.RoadmapBigType;
import com.sailfish.springbootdemo.service.db1.RoadmapBigTypeService;
import com.sailfish.springbootdemo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/roadmapBigType")
@CrossOrigin
public class RoadmapBigTypeController {

    @Autowired
    private RoadmapBigTypeService roadmapBigTypeService;

    @PostMapping("/getAllRoadmapBigType")
    public Result getAllRoadmapBigType(String searchValue) {
        try {
            return ResultUtil.success(roadmapBigTypeService.getAllRoadmapBigType(searchValue));
        } catch (Exception e) {
            e.printStackTrace();
            return ResultUtil.error(500, e.getMessage(), e.getMessage(), null);
        }
    }

    @PostMapping("/deleteRoadmapBigType")
    public Result deleteRoadmapBigType(Integer roadmapBigTypeId) {
        return roadmapBigTypeService.deleteRoadmapBigType(roadmapBigTypeId);
    }

    @PostMapping("/addOrUpdateRoadmapBigType")
    public Result addOrUpdateRoadmapBigType(String mode, RoadmapBigType roadmapBigType) {
        return roadmapBigTypeService.addOrUpdateRoadmapBigType(mode, roadmapBigType);
    }

    @PostMapping("/getH3cRoadmap")
    public Result getH3cRoadmap(Integer year, Integer versionY, String versionN) {
        return roadmapBigTypeService.getH3cRoadmap(year, versionY, versionN);
    }

    @PostMapping("/getH3cThreeYearRoadmap")
    public Result getH3cThreeYearRoadmap(Integer versionY, String versionN) {
        return roadmapBigTypeService.getH3cThreeYearRoadmap(versionY, versionN);
    }

    @PostMapping("/getCmRoadmapByCompany")
    public Result getCmRoadmapByCompany(Integer pcbaCompanyId, Integer versionY, String versionN) {
        return roadmapBigTypeService.getCmRoadmapByCompany(pcbaCompanyId, versionY, versionN);
    }

    @PostMapping("/getCmRoadmapByCompanyIdsAndCalcCapacityIsMatch")
    public Result getCmRoadmapByCompanyIdsAndCalcCapacityIsMatch(String pcbaCompanyIdsStr, Integer year, Integer versionY, String versionN) {
        return roadmapBigTypeService.getCmRoadmapByCompanyIdsAndCalcCapacityIsMatch(pcbaCompanyIdsStr, year, versionY, versionN);
    }
}
